{%include file="index.header.tpl.php"%}
{%include file="index.left.tpl.php"%}
 <!--主要内容开始-->
  <div class="content-wrapper">
    <section class="content">
      <div class="row">
        <section class="col-lg-12 connectedSortable">
         <div class="box box-default box-solid">
             <form name="myform" action="" method="get">	
                <div class="box-header with-border">
                    <span class="fa  fa-volume-up" style="float:left; font-size:18px; padding-top:3px; color:#3c8dbc;" ></span>
                    <a href="index.php?a=inform.superiorlist&inform_type={%$inform_type%}" class="btn btn-primary">上级通知</a>
                    <a href="index.php?a=inform.dispenselist&inform_type={%$inform_type%}" class="btn btn-default">分发列表</a>
					<a href="index.php?a=inform.superioradd&inform_type={%$inform_type%}" class="btn btn-primary btn-sm" style="float:right; color:#fff;">新 增</a>
                </div>
                <div class="box-body">
                    <div class="col-md-2 form-group" style="padding:0;">
						  <label for="inputPassword3" class="col-sm-5 control-label text-right" style="padding:0;font-weight:500; margin:0;">
							   标题：
						  </label>
						  <div class="input-group col-sm-7 col-xs-12">
							    <input type="text" class="form-control" name="inform_title" value="{%$inform_title%}">
						  </div> 
				    </div>

					<div class="col-md-3 form-group" style="padding:0;">
						  <label for="inputPassword3" class="col-sm-6 control-label text-right" style="padding:0;font-weight:500; margin:0;">
							   上级部门：
						  </label>
						  <div class="input-group col-md-6 col-xs-12">
							    <select class="form-control" name="up_id">
								<option value="">全部</option>
								{%foreach from=$up_lists key=key item=value%}
									<option value="{%$value.up_id%}"{%if $value.up_id==$up_id%}selected{%/if%}>{%$value.up_name%}</option>
								{%/foreach%}
								</select> 
						  </div> 
				    </div>
					<div class="col-md-5 col-xs-12 form-group" style="padding:0;">
						  <label for="inputPassword3" class="col-sm-3 control-label text-right" style="padding:0;font-weight:500; margin:0;">
							  要求完成时间：
						  </label>
						  <div class="input-group col-md-4" style="float:left;">
							   <input type="text" class="form-control" value="{%$from%}" id="from" name="from">
							     <div class="input-group-addon" style="padding:6px 7px;">
									<i class="fa fa-calendar"></i>
								 </div>
						  </div>
						  <span style="float:left;">  ~  </span >
						  <div class="input-group col-md-4" style="float:left;">
							   <input type="text" class="form-control" value="{%$to%}" id="to" name="to">
							      <div class="input-group-addon" style="padding:6px 7px;">
									 <i class="fa fa-calendar"></i>
								 </div>
						  </div>						  
				    </div>
					<div class="col-md-1 col-xs-12">
					   <input type="hidden" name="a" value="inform.superiorlist">
					   <input type="hidden" name="inform_type" value="{%$inform_type%}">
					   <button type="submit" class="btn btn-warning">查 询</button>
					</div>
					</form>	
					<form name="myform" action="" method="get">	
					<div style="clear:both; height:10px;"></div>

                     <table class="table table-bordered table-striped"  id="mytable">
                                <thead>
                                    <tr style=" background-color:#a273ff;">
                                        <td>标题</td>
                                        <td>文档号</td>
										<td>上级部门</td>
										<td>下达时间</td>
                                        <td>要求完成时间</td>
                                        <td>备注</td>
                                        <td>附件</td>
                                        <td>操作</td>
                                    </tr>	
                                </thead>
                                <tbody>
								{%foreach from=$inform_lists key=key item=value%}
                                    <tr>
                                        <td><a href="index.php?a=inform.superiordetails&inform_type={%$inform_type%}&inform_id={%$value.inform_id%}">{%$value.inform_title%}</a></td>
                                        <td>{%$value.inform_num%}</td>
										<td>{%$value.up_name%}</td>
                                        <td>{%$value.start_time%}</td>
                                        <td>{%$value.end_time%}</td>
                                        <td>{%$value.inform_content%}</td>
                                        <td>{%$value.inform_file%}</td>
                                        <td>
                                             <a class="btn btn-warning btn-sm" href="index.php?a=inform.superiorupdate&inform_type={%$inform_type%}&inform_id={%$value.inform_id%}" title="修改"><i class="fa fa-edit (alias)"></i></a>
                                             <a class="btn btn-danger btn-sm" href="index.php?a=inform.superiordel&inform_type={%$inform_type%}&inform_id={%$value.inform_id%}" title="删除" onclick="if(confirm('警告！确认删除信息?')==false)return false;"><i class="fa fa-trash"></i></a>
                                        	 <span class="btn btn-success btn-sm"  data-toggle="modal" data-target="#myModal" title="分发" onClick="show('{%$value.inform_id%}')">
											 <i class="fa fa-share (alias)"></i>
											 </span>
                                        </td>
                                    </tr>	
                                {%/foreach%}   
                            </tbody>
                        </table>
				   </div><!--box-body -->
				   <div class="box-footer">
				   {%$page%}
				   </div>
               </form>
           </div><!--box box-default box-solid-->
        </section>   
           
        </div><!--row-->
    </section>
 </div>
  <!--主要内容结束-->
{%include file="index.footer.tpl.php"%}
<!--弹出框-->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
  <div class="modal-dialog" style="width:800px;">
	<div class="modal-content" style="margin-top:120px;">
	  <form name="form2" action="" method="post">
		  <div class="modal-header">
			<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
			<h4 class="modal-title" id="myModalLabel">选择分发对象 ：</h4>
		  </div>
		  <div class="modal-body">
			  <div class="form-group">
					  <div class="col-sm-1" style="padding:0;">
						   <label id="jiao" style="font-weight:100;">选择教师</label>
					  </div>
					  <div class="col-sm-11 col-xs-10">
								 
								<div class="col-sm-12">
											<ul id="tree2" class="ztree"></ul>
								</div>
					  </div>
				</div>
				<div style="clear:both; height:10px;"></div>
				<div class="form-group">
					 <div class="col-sm-1" style="padding:0;">
						   <label id="jiao" style="font-weight:100;">选择学生</label>
					  </div>
					  <div class="col-sm-10 col-xs-10">
							  <div class="col-sm-12">
								   <ul id="treeDemo" class="ztree"></ul>
								   <div style="display:none;">
										被勾选时：<input type="checkbox" id="py" class="checkbox first" checked /><span>关联父</span>
										<input type="checkbox" id="sy" class="checkbox first" checked /><span>关联子</span><br/>
										取消勾选时：<input type="checkbox" id="pn" class="checkbox first" checked /><span>关联父</span>
										<input type="checkbox" id="sn" class="checkbox first" checked /><span>关联子</span><br/>
									</div>
							  </div>
					  </div> 
				</div>  
		  </div>
		  <div style="clear:both;"></div>
						<div id="hiddenBox"></div>
		  <div class="modal-footer">
			<input type="hidden" name="inform_id" value="" id="aaa">
			<button type="submit" class="btn btn-primary"  onclick="c();" >确定</button>
		  </div>
	  </form>
	</div>
  </div>
</div>
<!--弹出框-->
<script>

function show(a){
	
	$("#aaa").val(a);
	
	}

</script>
<script>
  $(function() {
    $( "#from" ).datepicker({
      defaultDate: "+1w",
      changeMonth: true,
	  changeYear: true,
      numberOfMonths:1,
      onClose: function( selectedDate ) {
        $( "#to" ).datepicker( "option", "minDate", selectedDate );
      }
    });
    $( "#to" ).datepicker({
      defaultDate: "+1w",
      changeMonth: true,
      changeYear: true,
      numberOfMonths:1,
      onClose: function( selectedDate ) {
        $( "#from" ).datepicker( "option", "maxDate", selectedDate );
      }
    });
  });
  </script>

<script src="static/js/jquery.ztree.core.js"></script><!--树形-->
<script src="static/js/jquery.ztree.excheck.js"></script><!--树形-->
 
<script>
     var setting = {
            check: {
                enable: true
            },
            view:{
                showIcon:false
            },
              
            data: {
                simpleData: {
                    enable: true
                }
            }
        };
        var ztNodes =[
		    { id:"g0", pId:0, name:"全体教师"},
			{ id:"g1", pId:"g0", name:"部门"},
			{%foreach from=$department_lists key=key item=value%}
				{ id:"bm_{%$value.department_id%}", pId:"g1", name:"{%$value.department_name%}", },
			{%/foreach%}			
			{%foreach from=$department_name key=key item=value%}
				{ id:"user_{%$value.user_id%}", pId:"bm_{%$value.department_id%}", name:"{%$value.staff_name%}", },
			{%/foreach%}
			{ id:"g2", pId:"g0", name:"教研组"},
			{%foreach from=$research_lists key=key item=value%}
				{ id:"xka_{%$value.research_id%}", pId:"g2", name:"{%$value.research_name%}", },
			{%/foreach%}
			{%foreach from=$research_name key=key item=value%}
				{ id:"user_{%$value.user_id%}", pId:"xka_{%$value.research_id%}", name:"{%$value.staff_name%}", },
			{%/foreach%}
			{ id:"g3", pId:"g0", name:"备课组"},
			{%foreach from=$prepare_lists key=key item=value%}
				{ id:"xkb_{%$value.prepare_id%}", pId:"g3", name:"{%$value.prepare_name%}", },
			{%/foreach%}
			{%foreach from=$prepare_name key=key item=value%}
				{ id:"user_{%$value.user_id%}", pId:"xkb_{%$value.prepare_id%}", name:"{%$value.staff_name%}", },
			{%/foreach%}
			{ id:"g4", pId:"g0", name:"学科组"},
			{%foreach from=$discipline_lists key=key item=value%}
				{ id:"xkc_{%$value.discipline_id%}", pId:"g4", name:"{%$value.discipline_name%}", },
			{%/foreach%}
			{%foreach from=$discipline_name key=key item=value%}
				{ id:"user_{%$value.user_id%}", pId:"xkc_{%$value.discipline_id%}", name:"{%$value.staff_name%}", },
			{%/foreach%}
			
];
        var ztcode;
        function setCheck1() {
            var zTree = $.fn.zTree.getZTreeObj("tree2"),
            py = $("#py").attr("checked")? "p":"",
            sy = $("#sy").attr("checked")? "s":"",
            pn = $("#pn").attr("checked")? "p":"",
            sn = $("#sn").attr("checked")? "s":"",
            type = { "Y":py + sy, "N":pn + sn};
            zTree.setting.check.chkboxType = type;
            showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
        }
        function showCode1(str) {
            if (!ztcode) ztcode = $("#ztcode");
            ztcode.empty();
            ztcode.append("<li>"+str+"</li>");
        }
        $(document).ready(function(){
            $.fn.zTree.init($("#tree2"), setting, ztNodes);
            setCheck1();
            $("#py").bind("change", setCheck1);
            $("#sy").bind("change", setCheck1);
            $("#pn").bind("change", setCheck1);
            $("#sn").bind("change", setCheck1);
        });
</script>


<script type="text/javascript">
		var setting = {
			check: {
				enable: true,	
			},
			data: {
				simpleData: {
					enable: true
				}
			}
		};
		var zNodes =[
		{ id:"b0", pId:0, name:"全体学生", },
		{%foreach from=$grade_lists key=key item=value%}
			{ id:"g_{%$key%}", pId:"b0", name:"{%$value%}", open:true},
		{%/foreach%}
		{%foreach from=$class_lists key=key item=value%}
			{ id:"c_{%$value.class_id%}", pId:"g_{%$value.grade_id%}", name:"{%$value.class_name%}", open:true},
		{%/foreach%}
		{%foreach from=$student_lists key=key item=value%}
			{ id:"user_{%$value.user_id%}", pId:"c_{%$value.class_id%}", name:"{%$value.student_name%}", {%if $value.is_check=='1'%}checked:true,{%/if%} open:true, last:true},
		{%/foreach%}
		];
		var code;
		
		function setCheck() {
			var zTree = $.fn.zTree.getZTreeObj("treeDemo"),
			py = $("#py").attr("checked")? "p":"",
			sy = $("#sy").attr("checked")? "s":"",
			pn = $("#pn").attr("checked")? "p":"",
			sn = $("#sn").attr("checked")? "s":"",
			type = { "Y":py + sy, "N":pn + sn};
			zTree.setting.check.chkboxType = type;
			showCode('setting.check.chkboxType = { "Y" : "' + type.Y + '", "N" : "' + type.N + '" };');
		}
		function showCode(str) {
			if (!code) code = $("#code");
			code.empty();
			code.append("<li>"+str+"</li>");
		}
		$(document).ready(function(){
			$.fn.zTree.init($("#treeDemo"), setting, zNodes);
			setCheck();
			$("#py").bind("change", setCheck);
			$("#sy").bind("change", setCheck);
			$("#pn").bind("change", setCheck);
			$("#sn").bind("change", setCheck);
		});
function c()
{
	var delidID = "";
	var zTree = $.fn.zTree.getZTreeObj("treeDemo").getCheckedNodes(true);//获取所有选中状态的节点  
	for (var i = 0; i < zTree.length; i++) {  
		//delidID += zTree[i].id + ",";
		$("#hiddenBox").append('<input type="hidden" name="pid[]" value="'+zTree[i].id+'">');
	}
	var zTree = $.fn.zTree.getZTreeObj("tree2").getCheckedNodes(true);//获取所有选中状态的节点  
	for (var i = 0; i < zTree.length; i++) {  
		//delidID += zTree[i].id + ",";
		$("#hiddenBox").append('<input type="hidden" name="pid[]" value="'+zTree[i].id+'">');
	}
} 		
</script>
